﻿using AutoMapper;
using B.S.Production.Domain.Entities;
using B.S.Production.ErrorCode;
using B.S.Production.Write.API.Application.Command.BomMainMaterialsRequiredCommand;
using B.S.Production.Write.API.Application.Command.MaterialsRequiredCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions;

namespace B.S.Production.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MaterialsRequiredController : ControllerBase
    {
        private readonly IMediator mediator;

        public MaterialsRequiredController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 所需物料添加
        /// </summary>
        /// <param name="command">实体</param>
        /// <returns></returns>
        /// 
        [HttpPost]
        
        public async Task<ApiResult<int>> AddMaterialsRequired(AddMaterialsRequiredCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 所需物料删除
        /// </summary>
        /// <param name="command">实体</param>
        /// <returns></returns>
        /// 
        [HttpDelete]
        public async Task<ApiResult<int>> DeleteMaterialsRequired([FromQuery]DeleteMaterialsRequiredCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 所需物料修改
        /// </summary>
        /// <param name="command">实体</param>
        /// <returns></returns>
        /// 
        [HttpPut]
        public async Task<ApiResult<int>> UpdateMaterialsRequired(UpdateMaterialsRequiredCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 所需物料添加
        /// </summary>
        /// <param name="command">实体</param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<ApiResult<int>> AddBomMainMaterialsRequired(AddBomMainMaterialsRequiredCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
